package com.ego.dubbo.service.impl;

import com.ego.dubbo.service.TbItemCatDubboService;
import com.ego.mapper.TbItemCatMapper;
import com.ego.mapper.TbItemMapper;
import com.ego.pojo.TbItemCat;
import com.ego.pojo.TbItemCatExample;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TbItemCatDubboServiceImpl implements TbItemCatDubboService {

    @Autowired
    private TbItemCatMapper tbItemCatMapper;

    /**
     * 根据父Id查询所有子类目
     * @param pid 父Id
     * @return 返回子类目
     */
    @Override
    public List<TbItemCat> selectByPid(Long pid) {
        TbItemCatExample example = new TbItemCatExample();
        example.createCriteria().andParentIdEqualTo(pid);
        this.tbItemCatMapper.selectByExample(example);
        return this.tbItemCatMapper.selectByExample(example);
    }

    /**
     * 根据主键查询商品类目，在规格参数界面显示
     * @param id
     * @return
     */
    @Override
    public TbItemCat selectById(Long id) {
        return this.tbItemCatMapper.selectByPrimaryKey(id);
    }

    @Override
    public TbItemCat selectByid(Long id) {
        return this.tbItemCatMapper.selectByPrimaryKey(id);
    }
}
